import { Injectable, ServiceUnavailableException } from '@nestjs/common';
import { PromotionService } from 'src/module/grocery/service/promotion.service';

@Injectable()
export class PromotService {
  constructor(private readonly promotService: PromotionService) {}

  async findOne(id: number) {
    const res = await this.promotService.findOne(id);
    return res;
  }

  async findAll(pageDto: { pageNo: number; pageSize: number }) {
    try {
      const params = {
        pageDto,
        queryDto: {
          id: null,
          title: '',
          desc: '',
          categoryId: null,
          goodsId: null,
        },
      };
      const res = await this.promotService.findAll(params);
      return res;
    } catch(e) {
      throw new ServiceUnavailableException(e);
    }
  }
}
